import autoImport from 'unplugin-auto-import/vite'
import IconsResolver from 'unplugin-icons/resolver'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

export default function createAutoImport() {
    return autoImport({
        imports: [
            'vue',
            'vue-router',
            'pinia',
        ],
        include: [
            /\.[tj]sx?$/,
            /\.vue$/,
            /\.vue\?vue/,
        ],
        resolvers: [
            // 自动导入 Element Plus 相关函数，如：ElMessage, ElMessageBox... (带样式)
            ElementPlusResolver(),
            // 自动导入图标组件
            IconsResolver({
                prefix: 'Icon',
            })
        ],
        vueTemplate: true, // 是否在 vue 模板中自动导入
        dts: "types/auto-imports.d.ts",
        cache: true
    })
}
